Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

How do you add a date as part of a record in asp

Options
  • 04-07-2002 10:55pm
    #1
    Registered Users Posts: 2,660 ✭✭✭


    I've been searching for hours for this, and it appears that every single tutorial stops short of telling you how to add a date. Does it have to be a certain syntax, can you just use Date(), is it considered a string or a number or something else? I cannot find the answer to these questions anywhere. Quite annoying.

    Just to clarify a little, I am trying to add a record to a database and one of the fields of the record is a date, and I'm using SQL through asp to add the records, so I'm wondering how it is achieved.


Comments

  • Registered Users Posts: 11,987 ✭✭✭✭zAbbo


    hmm not sure what you mean but

    <%
    Response.Write Now
    %>

    Will return the date and time on screen

    With customisations including :
    <%
    Response.Write “Year: ” & Year (Now)
    Response.Write “Month: ” & Month (Now)
    Response.Write “MonthName: ” & MonthName (Month(Now))
    Response.Write “Hour: ” & Hour (Now)
    Response.Write “Minute: ” & Minute (Now)
    Response.Write “Second: ” & Second (Now)
    %>

    Think that should be all that you require. I`m sure you can config this to be added into a record

    eg

    Dim date as string
    date = now

    etc.


  • Registered Users Posts: 437 ✭✭Spunj


    Dates are a funny data type, they really depend on what backend you are trying to save to. For instance in Access, you can put # around dates but thats pretty specific to it. I presume you are using SQL Server, so the best way (most unambiguous to the date setting on the server) is to use a date like this;

    INSERT INTO tblStuff (RECID, MYDATE)
    VALUES (100, '2002-JUL-04')

    If you use values like '04/07/2002' its will produce unpredictable results depending on server using 'MM/DD' or 'DD/MM' for day month :)

    - Spunj


  • Registered Users Posts: 14,761 ✭✭✭✭Winters


    If your using it to add information into a database, in Access, just have the date table auto add the date for you by having the default value set to: Date() or Now()

    Now() will display both the date and time and date() will only show the date in figures. Try the following asp resources if you need help:

    http://webwizguide.com
    I cant think of anymore off the top of my head.. ill post more later if you need them.... night night.


  • Registered Users Posts: 2,660 ✭✭✭Baz_


    Originally posted by Spunj
    Dates are a funny data type, they really depend on what backend you are trying to save to. For instance in Access, you can put # around dates but thats pretty specific to it. I presume you are using SQL Server, so the best way (most unambiguous to the date setting on the server) is to use a date like this;

    INSERT INTO tblStuff (RECID, MYDATE)
    VALUES (100, '2002-JUL-04')

    If you use values like '04/07/2002' its will produce unpredictable results depending on server using 'MM/DD' or 'DD/MM' for day month :)

    - Spunj

    tis actually access im using should have said that, but im gonna try variations on what youve just said, but if you have exactly what i need it would be most excellent.

    Thank you spunj my asp hero :)


  • Registered Users Posts: 2,660 ✭✭✭Baz_


    WOOHOO!! Got it working thanks to Spunj, which means that we now have to get married (I'd be a fool after all to let someone of your intellect get away) :)

    Anyway, sincerest thanks to spunj, and thanks to winters and bazh for their replies too.

    Boards.ie pwns google btw!!


  • Advertisement
  • Registered Users Posts: 19,396 ✭✭✭✭Karoma


    If you use values like '04/07/2002' its will produce unpredictable results depending on server using 'MM/DD' or 'DD/MM' for day month :)

    - Spunj

    <%@ LCID=6153 %> setting the locale should help with this...


Advertisement