A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Access Modules



 
 
Thread Tools Display Modes
  #1  
Old May 24th, 2004, 07:14 AM
Tausif Alam
external usenet poster
 
Posts: n/a
Default 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  
Old May 24th, 2004, 08:22 PM
John Spencer (MVP)
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:56 PM.


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