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!

Date format YYYY/MM/DD 1

Status
Not open for further replies.

Periko

Programmer
Feb 24, 2003
134
BE
Hi,

I have to compare a databasefield stored as YYYY/MM/DD with the current date.

So I want to have my current date (in a variable) transformed to YYYY/MM/DD.

Is this possible in ASP ?

Thx in advance

Pedro

"Live is Music
 
just one word extra.
In visual basic i used to type : cdate = format(now, "yyyy/mm/dd). This seems not to work in asp.

Has anybody an idea ?

Pedro...
 
You can flip a date around with something like (you can make it slightly shorter, but I just want to make each step clear):
Code:
'assumes "YourDate" is the date you want to convert

Dim strYear, strMonth, strDay, strNewDate

strYear = Year(YourDate)

If Month(YourDate) < 10 Then
    strMonth = "0" & Month(YourDate)
Else
    strMonth = Month(YourDate)
End If

If Day(YourDate) < 10 Then
    strDay = "0" & Day(YourDate)
Else
    strDay = Day(YourDate)
End If

strNewDate = strYear & "/" & strMonth & "/" & strDay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top