Results 1 to 6 of 6

Thread: [RESOLVED] Update Field Daily Routine forgot how

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Resolved [RESOLVED] Update Field Daily Routine forgot how

    i want to update a date field every day that passes but i forgot how

    do i need to use Cdate or Date Add?
    e.x if today is 28-03-2015 then i will update the field to 29-03-2015
    and so on
    Code:
     StrSql = "Update SendZTotalToCelular Set Zdate = " ' Here i need to make the update
     CN.Execute StrSql
    tnx for any help
    salsa31

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Update Field Daily Routine forgot how

    If zDate is a date field, and since this is Access, I think you can use a couple of choices:
    Zdate = DateAdd("d", 1, Zdate)
    Zdate = Zdate + 1

    IF ZDdate is a text field, you'll likely need to convert ZDate using CDate() before adding to it, then convert the result back to string to store in the database field
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: Update Field Daily Routine forgot how

    hey lavolpe the field is a Date / time
    dont i need a variable for the Zdate?
    dim Zdate as Date?

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Update Field Daily Routine forgot how

    Zdate is also the name of the field? If so, does this statement work for you?
    Code:
    "Update SendZTotalToCelular Set Zdate = Zdate + 1"
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: Update Field Daily Routine forgot how

    tnk you very much sir

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: [RESOLVED] Update Field Daily Routine forgot how

    Using the date +1 does not sound like the right approach to me here. If I am understanding correctly what you want is today's date. If that be the case then using date +1 can lead to corrupted data and a headache down the line. If the program is always running or runs every day then date +1 would work out to give today's date but if for some reason there is a day that the program is not ran the date would be off by one or more days and would be off on every day that follows over time it could be off my several days or even weeks.

    Sounds like you need to use the actual date rather than adding to what is there already

Posting Permissions

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



Click Here to Expand Forum to Full Width