Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Date formatting 1

Status
Not open for further replies.

JLeo

Technical User
Feb 10, 2003
44
US
Hi,

Need some help as i'm stuck with this niggling prob...

I wish to assign the the current day, month and year to 3 seperate variables using:

CurrDay = Day(Date)
CurrMth = Month(Date)
CurrYear = Year(Date)

Looks simple n straightfoward but it returns garbage, after a few inspections, i realised that the 'Date' function returns todays date as 110603(DDMMYY format) and hence it can't recongnise the day, mth or year correctly.

I believe that this should work fine as long as the 'Date' function returns in the DD/MM/YY format. Can anyone advice how to format the date accordingly??

Thanks alot in advance.
 
Jleo

I think you need to read up on the datepart function. This can be used to extract the individual bits of the specified control.

In your case the function would be as follows

currday=Datepart("d",Now()) where Now() is the current date.

Alternatively you can use the same function that you were using. However, instead of Day(Date), try using Day(Now()).

The Now() function will return todays date

HTH

Elise
 
Hi Elise,

Jus as simple as that, the 'Now()' function has solved my problem. To think I spent 3 hours trying to get the 'Date' function to work correctly.

A star to show my apprecieation. Thanks.

Cheers
 
NOMB - None Of My Business, but...

On my PC here in New York:

?date
6/13/03

?now
6/13/03 3:07:52 PM

Notice the date portion's are formatted the same.

So I'm wondering if JLeo has European set as his default date format. And if he does, if he ?date and ?now,
do they return different formats?

Just wondering,
Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top