[Solved] Get the Previous Sunday from a Date

Post

Posted
Rating:
#26
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

BruceSteers said

grayghost4 said

I read the original post  as wanting the sunday of the last full week to print the last week activity report.

 as I need to get the Sunday to Monday dates for a report that run for the previous week (no matter what day the report would be run this week it would always report back the previous Monday to Sunday dates)

Mabe I did not understand what he needed   ;)

for me it was a good exersize and learing how to use some of the date functions  :D

rereading the OP i guess he wants the Monday of the last full week … so just remove the "-1" from the iDay and print the following sunday

Code (gambas)

  1.    If iDay = 6 Then iDay = -1    ' Move sat to begining of week
  2.    Print Date(DateAdd(Now, gb.Day, -(iDay) - gb.Week))
  3.    Print Date(DateAdd(Now, gb.Day, -iDay))
  4.  

I think he wants a few things, as soon as i solved one issue he asked for another variant.

I'm pretty sure he's been given enough help/information needed to make the function/functions work how he needs it to now.

I think his biggest issue at first was he was adding integer values directly to date objects and that's a no no that's bound to cause problems
Now he knows to use DateAdd instead and has been shown a few tricks on how to get from one day to another.

I'm pretty sure he's now well equipped to figure out all he needs to :)


He is WELL equipped to sort the rest of the issues out thank you to EVERYONE who has posted a example the different examples on here are showing me a lot on how the DateAdd works so I very much appreciate that.

And like the saying goes "Give a man a fish he will eat for a day, Teach him to fish he will eat for life" and that is the same with Gambas I have managed (With help from everyone on here) to do some VERY advanced Functions and features that I could only dream about on the Windows version of my Point of sale system.
Online now: No Back to the top
1 guest and 0 members have just viewed this.