Time question - add 15 minutes

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Time question - add 15 minutes

    I have a time field in an access database and I want to be able to add 15
    minutes to it.

    I can do this manually by taking the minute, adding 15 and then if it is
    over 60, changing the hour, but is there an easier way like with adding a
    day to a date by simply adding 1?

    Many thanks


    Digit24 Guest

  2. Similar Questions and Discussions

    1. Convert minutes to Hours and Minutes
      Hi There It's getting late and my brain is feeling like a Larne sausage :-) What I want to achieve is to convert a total number of minutes into...
    2. how to time out the web asp.net application when not in use for 15 minutes
      Hi, How to timing out the asp.net web application when not in use for 15 minutes although I am using the code in web.config file as below: ...
    3. Time Format in datagrid (Hours, Minutes, Seconds)
      I have a column in my database that stores total seconds. I want to bind this colum to my datagrid. Is there a way to have the time show as hours,...
    4. Weird spike in System time every 5:00 minutes...
      Hi All, I have what I consider to be an odd behavior on some of my AIX boxes. So far, on most of the AIX servers I have that are running Sybase,...
    5. Calculate elapsed time in minutes
      Try: DateDiff("n",,) Your code has you comparing TaskStart to TaskStart and then dividing the result (which is in minutes from the 'n'...
  3. #2

    Default Re: Time question - add 15 minutes

    Digit24 wrote on 29 apr 2004 in microsoft.public.inetserver.asp.db:
    > I have a time field in an access database and I want to be able to add 15
    > minutes to it.
    >
    > I can do this manually by taking the minute, adding 15 and then if it is
    > over 60, changing the hour, but is there an easier way like with adding a
    > day to a date by simply adding 1?
    >
    Using MS jet engine you will have to use a plain ASP-vbs loop, I think,
    with:


    newdatetime = DateAdd("n",olddatetime,15)

    ["n" for minute, "m" for month]

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan. Guest

  4. #3

    Default Re: Time question - add 15 minutes

    Digit24 wrote:
    > I have a time field in an access database and I want to be able to
    > add 15 minutes to it.
    >
    > I can do this manually by taking the minute, adding 15 and then if it
    > is over 60, changing the hour, but is there an easier way like with
    > adding a day to a date by simply adding 1?
    >
    > Many thanks
    UPDATE table
    SET [datefield] = DATEADD("n",15,[datefield])
    WHERE <primarykeyfield(s) = some criterial)

    HTH,
    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  5. #4

    Default Re: Time question - add 15 minutes

    "Evertjan." wrote in message news:Xns94DA810A1744Feejj99@194.109.133.29...
    : Digit24 wrote on 29 apr 2004 in microsoft.public.inetserver.asp.db:
    :
    : > I have a time field in an access database and I want to be able to add
    15
    : > minutes to it.
    : >
    : > I can do this manually by taking the minute, adding 15 and then if it is
    : > over 60, changing the hour, but is there an easier way like with adding
    a
    : > day to a date by simply adding 1?
    : >
    :
    : Using MS jet engine you will have to use a plain ASP-vbs loop, I think,
    : with:
    :
    :
    : newdatetime = DateAdd("n",olddatetime,15)
    :
    : ["n" for minute, "m" for month]

    DateAdd Syntax: DateAdd(interval, number, date)

    The interval argument can have the following values:
    Setting Description
    yyyy Year
    q Quarter
    m Month
    y Day of year
    d Day
    w Weekday
    ww Week of year
    h Hour
    n Minute
    s Second

    newdatetime = DateAdd("n", 15, now)

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - [url]http://www.microsoft.com/technet/scriptcenter/[/url]
    WSH 5.6 Documentation - [url]http://msdn.microsoft.com/downloads/list/webdev.asp[/url]
    MSDN Library - [url]http://msdn.microsoft.com/library/default.asp[/url]


    Roland Hall Guest

  6. #5

    Default Re: Time question - add 15 minutes

    Bob Barrows [MVP] wrote on 29 apr 2004 in
    microsoft.public.inetserver.asp.db:
    > Digit24 wrote:
    >> I have a time field in an access database and I want to be able to
    >> add 15 minutes to it.
    >>
    >> I can do this manually by taking the minute, adding 15 and then if it
    >> is over 60, changing the hour, but is there an easier way like with
    >> adding a day to a date by simply adding 1?
    >>
    >> Many thanks
    >
    > UPDATE table
    > SET [datefield] = DATEADD("n",15,[datefield])
    > WHERE <primarykeyfield(s) = some criterial)
    Can the jet engine do that?


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan. Guest

  7. #6

    Default Re: Time question - add 15 minutes

    Evertjan. wrote:
    > Bob Barrows [MVP] wrote on 29 apr 2004 in
    > microsoft.public.inetserver.asp.db:
    >
    >> Digit24 wrote:
    >>> I have a time field in an access database and I want to be able to
    >>> add 15 minutes to it.
    >>>
    >>> I can do this manually by taking the minute, adding 15 and then if
    >>> it is over 60, changing the hour, but is there an easier way like
    >>> with adding a day to a date by simply adding 1?
    >>>
    >>> Many thanks
    >>
    >> UPDATE table
    >> SET [datefield] = DATEADD("n",15,[datefield])
    >> WHERE <primarykeyfield(s) = some criterial)
    >
    > Can the jet engine do that?
    Yes. The Jet engine is able to utilize quite a few VBA functions. There are
    several which are considered "unsafe" and therefore not allowed (Replace,
    IIF, Nz, etc), but DATEADD is not restricted. You can see the list here:
    [url]http://support.microsoft.com/?id=294698[/url]

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  8. #7

    Default Re: Time question - add 15 minutes

    Bob Barrows [MVP] wrote on 29 apr 2004 in
    microsoft.public.inetserver.asp.db:
    > Yes. The Jet engine is able to utilize quite a few VBA functions.
    > There are several which are considered "unsafe" and therefore not
    > allowed (Replace, IIF, Nz, etc), but DATEADD is not restricted. You
    > can see the list here: [url]http://support.microsoft.com/?id=294698[/url]
    Interesting, thanks.

    So I could write:

    SQL = "UPDATE tblX SET Dat = DateAdd("h",1,Dat)"

    to correct a whole column of field "Dat"?

    Is the "SELECT Dat" action intrinsic to UPDATE?

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan. Guest

  9. #8

    Default Re: Time question - add 15 minutes

    Evertjan. wrote:
    > Bob Barrows [MVP] wrote on 29 apr 2004 in
    > microsoft.public.inetserver.asp.db:
    >
    >> Yes. The Jet engine is able to utilize quite a few VBA functions.
    >> There are several which are considered "unsafe" and therefore not
    >> allowed (Replace, IIF, Nz, etc), but DATEADD is not restricted. You
    >> can see the list here: [url]http://support.microsoft.com/?id=294698[/url]
    >
    > Interesting, thanks.
    >
    > So I could write:
    >
    > SQL = "UPDATE tblX SET Dat = DateAdd("h",1,Dat)"
    >
    > to correct a whole column of field "Dat"?
    Absolutely. It's safer to surround the column name with brackets, but the
    idea is correct.
    >
    > Is the "SELECT Dat" action intrinsic to UPDATE?
    Sorry, but I'm not sure about what you mean by "SELECT Dat" in relation to
    UPDATE queries.

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  10. #9

    Default Re: Time question - add 15 minutes

    Bob Barrows [MVP] wrote on 29 apr 2004 in
    microsoft.public.inetserver.asp.db:
    >> SQL = "UPDATE tblX SET Dat = DateAdd("h",1,Dat)"
    >>
    >> to correct a whole column of field "Dat"?
    >
    > Absolutely. It's safer to surround the column name with brackets, but the
    > idea is correct.
    >> Is the "SELECT Dat" action intrinsic to UPDATE?
    >
    > Sorry, but I'm not sure about what you mean by "SELECT Dat" in
    > relation to UPDATE queries.
    >
    UPDATE, to my simple mind, was a "write to database" action.

    SELECT a "read from database" action.

    Now it seems UPDATE can "read-change-write" in one go.

    [The name "UPDATE" should have informed me]

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan. Guest

  11. #10

    Default Re: Time question - add 15 minutes

    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:%23$Vn6lfLEHA.4052@TK2MSFTNGP11.phx.gbl...
    > Evertjan. wrote:
    > > Bob Barrows [MVP] wrote on 29 apr 2004 in
    > > microsoft.public.inetserver.asp.db:
    > >
    > >> Digit24 wrote:
    > >>> I have a time field in an access database and I want to be able to
    > >>> add 15 minutes to it.
    > >>>
    > >>> I can do this manually by taking the minute, adding 15 and then if
    > >>> it is over 60, changing the hour, but is there an easier way like
    > >>> with adding a day to a date by simply adding 1?
    > >>>
    > >>> Many thanks
    > >>
    > >> UPDATE table
    > >> SET [datefield] = DATEADD("n",15,[datefield])
    > >> WHERE <primarykeyfield(s) = some criterial)
    > >
    > > Can the jet engine do that?
    >
    > Yes. The Jet engine is able to utilize quite a few VBA functions.
    There are
    > several which are considered "unsafe" and therefore not allowed
    (Replace,
    > IIF, Nz, etc), but DATEADD is not restricted. You can see the list
    here:
    > [url]http://support.microsoft.com/?id=294698[/url]
    IIF is allowed. Let's hope that never changes. :) Also it's worth
    mentioning that the referenced article in not really applicable to ASP,
    but is geared more towards sandboxing user defined function from
    external access. For example a call from a Visual Basic app. Remember
    this thread?...

    [url]http://groups.google.com/groups?threadm=eM7hCy64DHA.2404%40TK2MSFTNGP12.phx .gbl[/url]

    HTH
    -Chris Hohmann


    Chris Hohmann Guest

  12. #11

    Default Re: Time question - add 15 minutes

    Evertjan. wrote:
    > Bob Barrows [MVP] wrote on 29 apr 2004 in
    > microsoft.public.inetserver.asp.db:
    >>> SQL = "UPDATE tblX SET Dat = DateAdd("h",1,Dat)"
    >>>
    >>> to correct a whole column of field "Dat"?
    >>
    >> Absolutely. It's safer to surround the column name with brackets,
    >> but the idea is correct.
    >
    >
    >>> Is the "SELECT Dat" action intrinsic to UPDATE?
    >>
    >> Sorry, but I'm not sure about what you mean by "SELECT Dat" in
    >> relation to UPDATE queries.
    >>
    >
    > UPDATE, to my simple mind, was a "write to database" action.
    >
    > SELECT a "read from database" action.
    >
    > Now it seems UPDATE can "read-change-write" in one go.
    >
    > [The name "UPDATE" should have informed me]
    I still don't see the word "SELECT" in the example UPDATE statement. But as
    far as that goes, there is nothing preventing you from using a subquery in
    an UPDATE statement:

    UPDATE sometable
    SET somefield = (SELECT somefield FROM othertable WHERE ...)
    WHERE ...

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  13. #12

    Default Re: Time question - add 15 minutes

    Yes you do it exactly like adding 1 to th date. In ASP, date and time are all one field, they are not 2 separate fields as in other environments (that I work in anyway). So if adding 1 day is done by " now + 1 " then adding 1 hour would be 1/24th of a day, ie " now + (1/24 * 1) " and 15 minutes might be
    " now + ( (1/24) / 60 ) * 15 ". Did it that way to show the calculation, but you can do it various different ways, but the priciple is fractions of 1 day.

    Hope this helps
    Marcus

    ************************************************** ********************
    Sent via Fuzzy Software @ [url]http://www.fuzzysoftware.com/[/url]
    Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
    fuzzysoftware@calfordgreen.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139