Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

LEGEND ,
Sep 04, 2008 Sep 04, 2008
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.


TOPICS
Server side applications
553
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 04, 2008 Sep 04, 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.
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 04, 2008 Sep 04, 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.
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 04, 2008 Sep 04, 2008
LATEST
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.
>>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines