DatePart Function, String Functions

NewfieSarah

Registered User.
Local time
Today, 00:31
Joined
Feb 11, 2005
Messages
193
DatePart Function (STRING)

Hey all I have a I was wondering if you knew how I can get a part of my datepart function out, I have taken the year from the the date with the date part function and now I need only the 05, so what can I do to get it out? Thanks MY CODE: Dim Num as string Num = DatePart("yyyy", STRDATE)
I looked up the code for a right function and it is suppose to work on a string, so I tryed it on this. My CODE:
Dim Year As String
Year = RIGHT(Num, 2)
I obtained a type mismatch WHY???
 
Last edited:
What datapart?... Do you want the '05' of '2005'?
 
DatePart() returns an Integer. Try: Num = Str(DatePart("yyyy", STRDATE))
 
I would like the 05. I didnt not know that it returned an integer. WOW! Thanks for the heads up I tryed it and it works, but I still cant get the 05, by using the RIGHT Function.
 
Your Year = RIGHT(Num, 2) should have returned "05", what did you get? By the way, year is an Access reserved word. Change it to MyYear or anything else.
 
I keep getting a type mismatch! My Code :
Dim Num As String
Dim count As String
Dim MYYEAR As String
Dim NUMBER As String

count = DCount("*", "Building")
count = count + 1
Num = Str(DatePart("yyyy", STRDATE))
MYYEAR = RIGHT(Num, 2)
' NUMBER = MYYEAR + " - " + count

PERMIT.SetFocus
PERMIT.Text = MYYEAR (NUMBER)
 
DCount() returns a numeric value in spite of the fact you said shove it into a string. The string concantenation character is & not +. What do you expect to happen with this line: PERMIT.Text = MYYEAR (NUMBER)
 
I have got it! it works great! Thanks for all the help
Dim myCount As Long
PERMIT.SetFocus
myCount = 1 + Nz(DCount("*", "Building"), 0)
PERMIT.Text = Format(STRDATE, "yy") & " - " & myCount
 

Users who are viewing this thread

Back
Top Bottom