Offset Internal Calendar by Plus/Minus 2 Days???
I have an application that converts dates between the two calendars in VB like this:
VB Code:
Dim dt as Date
dt = Date
Calendar = vbCalGreg
Msgbox dt
Calendar = vbCalHijri
Msgbox dt
This works fine, however the hijri calendar is not fixed like the gregorian calendar depending on moon sightings.
What I would like to do is find a way to offset the result returned by windows for the hijri calendar through either api calls or a setting in the registry.
Using Dateadd function is not a solution as the application uses the results in constructing a calendar. The solution must involve either api call or setting in the registry.
Any help would be appreciated. Thank you in advance.
Re: Offset Internal Calendar by Plus/Minus 2 Days???
Ok I found this on MSDN, however when I change the registry value it doesn't change anything. I tried rebooting and it still is not working.
http://www.microsoft.com/middleeast/...cCalendar.aspx
=============================
You can adjust the Hijri Calendar from your registry, by modifying the AddHijriDate key value at
HKEY_CURRENT_USER\Control Panel\International\ and setting it to one of the following values:
Value
Meaning
AddHijriDate-2 Subtract two days.
AddHijriDate Subtract one day.
(blank) No adjustment is necessary. (If the date has not been adjusted, this entry does not appear in the registry. If the date has been adjusted and then restored to its original value, this entry appears in the registry with no value.)
AddHijriDate+1 Add one day.
AddHijriDate+2 Add two days.
Re: Offset Internal Calendar by Plus/Minus 2 Days???
I still have not found a solution for this problem, so I will rephrase the question. Let us say I want the Date function of VB to return a date that is plus/minus the date but the same weekday.
For example today is Friday November 3rd 2006
I want the function to return Friday November 1st 2006.
The reason is that I build a picturebox calendar with the dates but for the Hijri calendar can be offset plus/minus 2 days.
Any ideas? Thank you for any assistance.
Re: Offset Internal Calendar by Plus/Minus 2 Days???
You can add or remove two days with the DateAdd() function:
VB Code:
Debug.Print DateAdd("d", 2, dt)
Debug.Print DateAdd("d", -2, dt)
But to be the same weekday... I can't see how's that possible :confused:
Re: Offset Internal Calendar by Plus/Minus 2 Days???
Thank you gavio but using Dateadd function is not a solution as the application uses the results in constructing the picturebox calendar. The solution must involve either an api call or setting in the registry. Unless there is another solution?
Re: Offset Internal Calendar by Plus/Minus 2 Days???
date will ruturn the current system date so this will return what you ask for
VB Code:
x = -2
mydate = Format(Date, "dddd ") & Format(DateAdd("d", x, Date), "dd") & Format(Date, "/mm/yyyy")
Debug.Print mydate ' Saturday 02/11/2006
Edit:
you can also try this to see if it gives any useful result
VB Code:
VBA.Calendar = vbCalHijri
Debug.Print Now
VBA.Calendar = vbCalGreg
Debug.Print Now