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


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 ....:)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dede11Author Commented:
note : the i am using hijri date ...
Hi dede11,
doesn't this work for hijri dates? (I don't know)

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Does datepart("m",datefield) not work?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gustav BrockCIOCommented:
As to this source:

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 ...


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
dede11Author Commented:

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

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

thanks again.. :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.