Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Gregorian Date from Hijri

the following function converts Gregorian Date to Hijri
But when I do the opposite it done work, I mean convert a Hijri date to
Gregorian.

Any Help?!!



Function DHijri(dtGegDate As Date) As String

' returns a date in Hijri format for a given western date
VBA.Calendar = vbCalHijri
DHijri = dtGegDate
VBA.Calendar = vbCalGreg

End Function

Thanks

Abdul

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Gregorian Date from Hijri

Abdul,
This seems to work

Public Function ChangeCalenderDate(InputDate As Date, _
ToHijri As Boolean, _
FormatStr As String) _
As String
Dim OldCalendar As VbCalendar
OldCalendar = Calendar

Calendar = -ToHijri
ChangeCalenderDate = Format(InputDate, FormatStr)
Calendar = OldCalendar

End Function

However according http://www.rabiah.com/convert/, this function gives a
result one day out, although the site does indicate this is possible, but
does not explain why.
If you real the Excel Help on this subject, you will see that you format
cells with either calendar.
As I never use any of this I can't help you as a lot of this depends on the
system/Excel version in use.

NickHK

"Abdul"
egroups.com...
the following function converts Gregorian Date to Hijri
But when I do the opposite it done work, I mean convert a Hijri date to
Gregorian.

Any Help?!!



Function DHijri(dtGegDate As Date) As String

' returns a date in Hijri format for a given western date
VBA.Calendar = vbCalHijri
DHijri = dtGegDate
VBA.Calendar = vbCalGreg

End Function

Thanks

Abdul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Gregorian Date from Hijri

thanks

How I could use this one as a formula in Excel

for eg.
In the function i posted if i type =DHijri(CellReference) it will
convert Gregorian to Hijri

now if I want to convert Hijri to Gregorian
=ChangeCalenderDate(CellReference) gives #Name! Error

Thanks


News wrote:
Abdul,
This seems to work

Public Function ChangeCalenderDate(InputDate As Date, _
ToHijri As Boolean, _
FormatStr As String) _
As String
Dim OldCalendar As VbCalendar
OldCalendar = Calendar

Calendar = -ToHijri
ChangeCalenderDate = Format(InputDate, FormatStr)
Calendar = OldCalendar

End Function

However according http://www.rabiah.com/convert/, this function gives a
result one day out, although the site does indicate this is possible, but
does not explain why.
If you real the Excel Help on this subject, you will see that you format
cells with either calendar.
As I never use any of this I can't help you as a lot of this depends on the
system/Excel version in use.

NickHK

"Abdul"
egroups.com...
the following function converts Gregorian Date to Hijri
But when I do the opposite it done work, I mean convert a Hijri date to
Gregorian.

Any Help?!!



Function DHijri(dtGegDate As Date) As String

' returns a date in Hijri format for a given western date
VBA.Calendar = vbCalHijri
DHijri = dtGegDate
VBA.Calendar = vbCalGreg

End Function

Thanks

Abdul


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Gregorian Date from Hijri

You have to make a Public function in a module.
Also notice that there are 3 arguments that you need to supply, not just
one.

NickHK

"Abdul"
roups.com...
thanks

How I could use this one as a formula in Excel

for eg.
In the function i posted if i type =DHijri(CellReference) it will
convert Gregorian to Hijri

now if I want to convert Hijri to Gregorian
=ChangeCalenderDate(CellReference) gives #Name! Error

Thanks


News wrote:
Abdul,
This seems to work

Public Function ChangeCalenderDate(InputDate As Date, _
ToHijri As Boolean, _
FormatStr As String) _
As String
Dim OldCalendar As VbCalendar
OldCalendar = Calendar

Calendar = -ToHijri
ChangeCalenderDate = Format(InputDate, FormatStr)
Calendar = OldCalendar

End Function

However according http://www.rabiah.com/convert/, this function gives a
result one day out, although the site does indicate this is possible, but
does not explain why.
If you real the Excel Help on this subject, you will see that you format
cells with either calendar.
As I never use any of this I can't help you as a lot of this depends on
the
system/Excel version in use.

NickHK

"Abdul"
egroups.com...
the following function converts Gregorian Date to Hijri
But when I do the opposite it done work, I mean convert a Hijri date to
Gregorian.

Any Help?!!



Function DHijri(dtGegDate As Date) As String

' returns a date in Hijri format for a given western date
VBA.Calendar = vbCalHijri
DHijri = dtGegDate
VBA.Calendar = vbCalGreg

End Function

Thanks

Abdul




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting hijri date to gregorian date Ramil Marbella Excel Discussion (Misc queries) 1 May 5th 21 10:08 AM
Convert date from Gregorian Calendar to Hijri Calendar H.Alkhodary Excel Discussion (Misc queries) 1 February 21st 09 10:11 AM
How to convert Gregorian date into Hijri Date in Excel 2007? Ahmed Excel Discussion (Misc queries) 2 February 6th 09 03:59 PM
dates format using gregorian and hijri calendars sarif Excel Discussion (Misc queries) 0 December 12th 07 05:40 AM
Convert a julian gregorian date code into a regular date Robert Excel Worksheet Functions 3 June 13th 06 07:03 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"