Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 01:43 PM
Keith
Guest
 
Posts: n/a
Default Date Function

I want to insert the current date into a form field as a default text.

However, when I use <%=Date()%> it insets the date in the format 6/9/2004.

How can I get it to insert the date in UK format (dd/mm/yyyy) using leading
0's for single numbers, so I end up with 09/06/2004?

Thanks


  #2  
Old July 19th, 2005, 01:43 PM
Hans
Guest
 
Posts: n/a
Default Re: Date Function

Maybe you can get some ideas here
http://www.aspfaq.com/show.asp?id=2313

/Hans


  #3  
Old July 19th, 2005, 01:43 PM
Aaron [SQL Server MVP]
Guest
 
Posts: n/a
Default Re: Date Function

Also see http://www.aspfaq.com/2260

--
http://www.aspfaq.com/
(Reverse address to reply.)




"Keith" <@.> wrote in message news:ehzKI5gTEHA.3988@TK2MSFTNGP10.phx.gbl...[color=blue]
> I want to insert the current date into a form field as a default text.
>
> However, when I use <%=Date()%> it insets the date in the format 6/9/2004.
>
> How can I get it to insert the date in UK format (dd/mm/yyyy) using[/color]
leading[color=blue]
> 0's for single numbers, so I end up with 09/06/2004?
>
> Thanks
>
>[/color]


  #4  
Old July 19th, 2005, 01:50 PM
Bullschmidt
Guest
 
Posts: n/a
Default Re: Date Function

To make a variable be in the format of dd/mm/yyyy (and the final line of
code can be modifed for other date formats), perhaps try something like
the following which you might even make into a function:

varFld = CDate(MyVariable)

intMonth = Month(varFld)
intDay = Day(varFld)
intYr = Year(varFld)

If intMonth < 10 Then
strMonth = "0" & CStr(intMonth)
Else
strMonth = CStr(intMonth)
End If

If intDay < 10 Then
strDay = "0" & CStr(intDay)
Else
strDay = CStr(intDay)
End If

strYr = Right(CStr(intYr), 4) ' And change the 4 to 2 for 2 year dates.

varFld = CStr(strDay & "/" & strMonth & "/" & strYr)

Best regards,
J. Paul Schmidt, Freelance ASP Web Consultant
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles