Ben_Entrew
Registered User.
- Local time
- Today, 08:05
- Joined
- Dec 3, 2013
- Messages
- 177
Hi all,
I want to add a string as year to a date.
Somehow it doesn't work out. It should extract all records with Valid_from = 01.01.2013 and valid_to = 31.12.2013. The Year assignment works.
Can somebody please help me?
Thanks in advance.
Regards,
Ben
I want to add a string as year to a date.
Somehow it doesn't work out. It should extract all records with Valid_from = 01.01.2013 and valid_to = 31.12.2013. The Year assignment works.
Can somebody please help me?
Thanks in advance.
Regards,
Ben
Code:
Public Sub BEN()
Dim strSQL As String
Dim t As Date, s As Date
DoCmd.SetWarnings False
Year = Right(pricedate, 4)
t = 1 / 1 / " & Year & "
s = 12 / 31 / " & Year & "
strSQL = "SELECT TRANSFER_PRICES.* INTO [TEMP] " & _
" FROM TRANSFER_PRICES " & _
" Where [Valid_from] = " & Format(t, "\#mm\/dd\/yyyy\#") & _
" AND [Valid_to] = " & Format(s, "\#mm\/dd\/yyyy\#")
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End Sub