If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Access Modules
Hi Guru,
I need your help again. I like to call a access Module in access query. But it gives me error. Module: ----------- Function GetDatePart(pDate As Date) As String Dim LYear As Integer Dim LMth As Integer Dim LDay As Integer 'Extract the year, month, and day values from the date parameter called pDate LYear = DatePart("yyyy", pDate) LMth = DatePart("m", pDate) LDay = DatePart("d", pDate) 'Format new number as a ddmmyyyy value GetDatePart = Right("00" & CStr(LMth), 2) & "/" & Right("00" & CStr(LDay), 2) & "/" & CLng(CStr(LYear)) End Function QUERY: ----------- SELECT GetDatePart(datestamp) from table1 Please guide me if I am doing any thing wrong. Tausif. |
#2
|
|||
|
|||
Access Modules
If DateStamp is a date field, all you need to do is to apply the format to it.
FORMAT(DateStamp,"DD/MM/YYYY") If DateStamp is not a date field, but a string that you want to formatted as a date then your code will fail since you are requiring an datetime variable as an input and a string is NOT a datetime variable. Tausif Alam wrote: Hi Guru, I need your help again. I like to call a access Module in access query. But it gives me error. Module: ----------- Function GetDatePart(pDate As Date) As String Dim LYear As Integer Dim LMth As Integer Dim LDay As Integer 'Extract the year, month, and day values from the date parameter called pDate LYear = DatePart("yyyy", pDate) LMth = DatePart("m", pDate) LDay = DatePart("d", pDate) 'Format new number as a ddmmyyyy value GetDatePart = Right("00" & CStr(LMth), 2) & "/" & Right("00" & CStr(LDay), 2) & "/" & CLng(CStr(LYear)) End Function QUERY: ----------- SELECT GetDatePart(datestamp) from table1 Please guide me if I am doing any thing wrong. Tausif. |
Thread Tools | |
Display Modes | |
|
|