Results 1 to 2 of 2

Thread: DateSerial

  1. #1

    Thread Starter
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152

    DateSerial

    Hi all,

    Not sure if this should be in this forum, or the database development one instead...so if this needs to be moved, let me know.

    Soo, I've just confused myself a bit since I need to change up some date criteria in some access queries.

    I'm currently using the following to calculate the first and last day of the current month.

    Code:
    Between 
    (DateSerial(Year(Date()), Month(Date()), 1)) and (DateSerial(Year(Date()), Month(Date()) + 1, 0))
    and I'm using its counter part here, to grab the first and last day of the previous month:

    Code:
    Between (DateSerial(Year(Date()),Month(Date())-1,1)) And (DateSerial(Year(Date()),Month(Date()),0))
    However, I am now in need of saying that the month begins on the 2nd week of the current month, and ends after the 1st week in the next month. (mondays to be exact)

    I'm hoping this can be achieved like the above so that I can use it as criteria in queries and not just pure VB code.

    Thanks for any assistance.
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: DateSerial

    you should be able to do like
    vb Code:
    1. dateserial(someyear, somemonth, (9 - Weekday(DateSerial(someyear, somemonth, 1), vbSunday)) Mod 7 + 1)
    add 7 to day for second week monday, add 1 to month for 1st monday next month
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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