Skip to main content
Inspiring
September 4, 2008
Question

how to get Now() to display as mm/dd/yyyy hh:mm:ss?

  • September 4, 2008
  • 3 replies
  • 565 views
I'm in the UK, and I have a form field that contains the value <%=Now()%> to
get todays date. This gives me the following date format dd/mm/yyyy
hh:mm:ss

This is then used to INSERT into an MSSQL datetime field.

However, when it inserts it reverts to mm/dd/yyyy hh:mm:ss.

How can I ensure that the date that is in my form field is submitted in the
mm/dd/yyyy hh:mm:ss format that my MSSQL datetime field requires?

Thanks.
Nath.


This topic has been closed for replies.

3 replies

Inspiring
September 4, 2008
Thanks Ken,

I decided, after looking at that function, to re-write the way dates are
submitted in my application.

Basically I've created three drop down menus, day, month, year, which a user
completes. I have each of these menus defaulting to todays day, month, year
though.

When submitted this then directs to a confirmation page, which has a field
whose value is a combination of the three drop down menus on the previous
page:
<input type="text"
value="<%=Request.Form("year")%><%=Request.Form("month")%><%=Request.Form("day")%>"
name="MyDateTimeField" />

It's then inserted from this page, in the right format.

I find dates probably the most confusing thing to understand about any kind
of web programming. You think "I'm just going to simply insert a date into
my database" and all kinds of weird things start happening. I'm self
taught, but even when I feel like I'm understanding dates, a different kind
of problem comes up and I'm back to sqaure one.

Thanks for helping out though. I will keep that function to hand.
Nathon.

"Ken Ford - *ACE*" <newsgroups2@fordwebs.com> wrote in message
news:g9ojvb$1e9$1@forums.macromedia.com...
> http://www.aspfree.com/c/a/ASP-Code/Format-DateTime-Function--fmtDateTime-by-Kevin-Turner/
>
> And using the fmtdateTime() funcion on that page it would look something
> like this:
>
> <input type="text" name="TodaysDate" id="TodaysDate" value="<%=
> fmtDateTime(Now(), "mm/dd/yyyy hh:mm:ss") %>" />
>
> Or you could try giving the field in the database a default value of
> getdate()
>
> --
> Ken Ford
> Adobe Community Expert Dreamweaver/ColdFusion
> Adobe Certified Expert - Dreamweaver CS3
> Fordwebs, LLC
> http://www.fordwebs.com
>
>
> "tradmusic.com" <sales@NOSHPAMtradmusic.com> wrote in message
> news:g9o7lj$idh$1@forums.macromedia.com...
>> I'm in the UK, and I have a form field that contains the value <%=Now()%>
>> to get todays date. This gives me the following date format dd/mm/yyyy
>> hh:mm:ss
>>
>> This is then used to INSERT into an MSSQL datetime field.
>>
>> However, when it inserts it reverts to mm/dd/yyyy hh:mm:ss.
>>
>> How can I ensure that the date that is in my form field is submitted in
>> the mm/dd/yyyy hh:mm:ss format that my MSSQL datetime field requires?
>>
>> Thanks.
>> Nath.
>>
>


Inspiring
September 4, 2008
http://www.aspfree.com/c/a/ASP-Code/Format-DateTime-Function--fmtDateTime-by-Kevin-Turner/

And using the fmtdateTime() funcion on that page it would look something
like this:

<input type="text" name="TodaysDate" id="TodaysDate" value="<%=
fmtDateTime(Now(), "mm/dd/yyyy hh:mm:ss") %>" />

Or you could try giving the field in the database a default value of
getdate()

--
Ken Ford
Adobe Community Expert Dreamweaver/ColdFusion
Adobe Certified Expert - Dreamweaver CS3
Fordwebs, LLC
http://www.fordwebs.com


"tradmusic.com" <sales@NOSHPAMtradmusic.com> wrote in message
news:g9o7lj$idh$1@forums.macromedia.com...
> I'm in the UK, and I have a form field that contains the value <%=Now()%>
> to get todays date. This gives me the following date format dd/mm/yyyy
> hh:mm:ss
>
> This is then used to INSERT into an MSSQL datetime field.
>
> However, when it inserts it reverts to mm/dd/yyyy hh:mm:ss.
>
> How can I ensure that the date that is in my form field is submitted in
> the mm/dd/yyyy hh:mm:ss format that my MSSQL datetime field requires?
>
> Thanks.
> Nath.
>

Inspiring
September 4, 2008
It is always advisable to store Datetime data in native format. You can then
format this in your front end to display as you wish.

"tradmusic.com" <sales@NOSHPAMtradmusic.com> wrote in message
news:g9o7lj$idh$1@forums.macromedia.com...
> I'm in the UK, and I have a form field that contains the value <%=Now()%>
> to get todays date. This gives me the following date format dd/mm/yyyy
> hh:mm:ss
>
> This is then used to INSERT into an MSSQL datetime field.
>
> However, when it inserts it reverts to mm/dd/yyyy hh:mm:ss.
>
> How can I ensure that the date that is in my form field is submitted in
> the mm/dd/yyyy hh:mm:ss format that my MSSQL datetime field requires?
>
> Thanks.
> Nath.
>