LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Something slightly harder...

Just looking at this forum for the first time and your query was posted
some time ago so I guess you've resolved it.

It caught my eye because I had a similiar thing in SQL which should work
in Excel-VB with suitable syntax change.

NB: Suitable for comparisons but NOT for calculating days between.

Public Function MyDateNum(MYDATE As Date) As Long 'converts SQL mm/dd/yy
or mm/dd/yyyy into a number yyyymmdd
On Error GoTo ERR_MyDateNum

Dim MYSTR As String
Dim MYPOS As Byte

MYSTR = Str(MYDATE)
'convert any two-digit year into a four-digit year
If Len(MYSTR) < 10 Then MYSTR = Left(MYSTR, Len(MYSTR) - 2) & "20" &
Right(MYSTR, 2)
MYPOS = InStr(1, MYSTR, "/")
MyDateNum = Val(Right(MYSTR, 4) & Mid(MYSTR, MYPOS + 1, 2) &
Mid(MYSTR, 2, MYPOS - 1))

EXIT_MyDateNum:
Exit Function
ERR_MyDateNum:
MsgBox Err.Description
MsgBox ("Please discontinue and call an Administrator")
MyDateNum = 20010101 'Error defaults to this date number
Resume EXIT_MyDateNum
End Function

"WHERE Val(Str(Year([tblCLAIMLINES].[clResDate])) +
Mid(Str([tblCLAIMLINES].[clResDate]),4,2) +
Mid(Str([tblCLAIMLINES].[clResDate]),1,2)) = " &
MyDateNum([Forms]![frmCLAIMANALYSIS]![txtDateFrom]) & " " & _
"AND Val(Str(Year([tblCLAIMLINES].[clResDate])) +
Mid(Str([tblCLAIMLINES].[clResDate]),4,2) +
Mid(Str([tblCLAIMLINES].[clResDate]),1,2)) <= " &
MyDateNum([Forms]![frmCLAIMANALYSIS]![txtDateTo]) & " " & _


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
harder than i thought Tomkat743 Excel Discussion (Misc queries) 2 March 9th 09 02:37 PM
Autofilter so different, harder to use drugrep Excel Discussion (Misc queries) 12 November 2nd 07 07:00 PM
Slightly OT (Maybe) printing problem Meebers Excel Worksheet Functions 3 July 9th 07 12:18 PM
This is A LOT harder than I thought it would be Robert Excel Discussion (Misc queries) 13 August 24th 05 12:20 AM
Things are getting a little harder! S.H.C New Users to Excel 3 April 13th 05 11:08 PM


All times are GMT +1. The time now is 05:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"