Link to home
Create AccountLog in
Avatar of dede11
dede11

asked on

retrive the number of month from date field ....

hi

I have a date field suppose (dateField) that I am attempting to use a query to determine the number of month....
for example, if the (dateField) is 30\4\1405 , I want to run a query that will return the  month (i.e. 4).  

thanks ....:)
Avatar of dede11
dede11

ASKER

note : the i am using hijri date ...
SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
As to this source:

http://www.islamicfinder.org/hijri_intro.php

this calender is not exact:

"Since the Islamic calendar is purely lunar, as apposed to solar or luni-solar,
the Muslim (Hijri) year is shorter than the Gregorian year by about 11 days .."

thus you'll have to run your own conversion routine, or convert it to the Gregorian calender where you can use the Month() function - but these months are different from yours ...

/gustav
Hello,

If the date is stored as text in your database, you want to extract a portion of that string using the backslash delimiter. The following function can help:

Function HijriDatePart(pvarDate, pintPart As Integer)

On Error Resume Next

    HijriDatePart = Null
    HijriDatePart = CInt(Val(Split(pvarDate, "\")(pintPart)))

End Function

Place it in a module and you can then use it in a query, noting that the day is part 0, the month part 1 and the year part 2.

    HijriMonth: HijriDatePart( strTheDateField, 1 )

You can also do it all in a query expression, but it gets a little messy:

    HijriMonth: Val(Mid(Left([strField],InStr(InStr([strField],'\')+1,[strField],'\')),InStr([strField],'\')+1))

Hope this helps
(°v°)
Avatar of dede11

ASKER


Hello  experts ...
      thanks for response ...,

  Month(datefield).........and ........datepart("m",datefield) worked perfect with hijri date....:)

thanks again.. :)