Hi!
I have recently created a calendar app at my company.
It works flawlessly on a computer, but when opening the same app on my iPhone, there is trouble due to the DateFormat.
1. When I open the calendar screen i use the following code to set:
- First date of this month
- First day of this months calendar view (for October it is 26. September, since we use a Monday - Sunday week).
- Last day of this months calendar view (for October it is 06. Sovember)
Set(varMonth,DateValue(Month(Today()) & "/" & "1" & "/" & Year(Today())));
Set(varFirstDayView, DateAdd(varMonth, - Weekday(varMonth,Monday), Days));
Set(varFirstDayNextMonth, DateAdd(DateAdd(varMonth, 1, Months), 7 - Weekday(DateAdd(varMonth, 1, Months),Monday), Days));
As I have said, this works fine on my computer. But on my phone the date format automatically is set to dd.mm.yyyy, making all the formulas to fail.
I have tried several methods:
- DateValue(xx,"different language codes")
- Formatting the dates in the code, but I have not yet found a way.
Is there a simple way to make thise code work on any device? Cheers!
The code for going to the next month:
Set(varMonth,DateAdd(varMonth,1, Months));
Previous month:
Set(varMonth,DateAdd(varMonth,-1, Months));
Solved! Go to Solution.
Solved it.
Set(varMonth,DateValue(Month(Today()) & "/" & "1" & "/" & Year(Today()),"en"));
Set(varFirstDayView, DateValue(DateAdd(varMonth, - Weekday(varMonth,Monday), Days)));
Set(varFirstDayNextMonth, DateValue(
Text(
DateAdd(
DateAdd(DateValue(Text(varMonth,"mm/dd/yyyy"),"en"), 1, Months),
7 - Weekday(DateAdd(DateValue(Text(varMonth,"mm/dd/yyyy"),"en"), 1, Months),Monday),
Days),
"mm/dd/yyyy"),
"en"));
//////////////////
Set(varMonth,DateAdd(DateValue(Text(varMonth,"mm/dd/yyyy"),"en"),1, Months));
Now it work both on PC and phone.
Solved it.
Set(varMonth,DateValue(Month(Today()) & "/" & "1" & "/" & Year(Today()),"en"));
Set(varFirstDayView, DateValue(DateAdd(varMonth, - Weekday(varMonth,Monday), Days)));
Set(varFirstDayNextMonth, DateValue(
Text(
DateAdd(
DateAdd(DateValue(Text(varMonth,"mm/dd/yyyy"),"en"), 1, Months),
7 - Weekday(DateAdd(DateValue(Text(varMonth,"mm/dd/yyyy"),"en"), 1, Months),Monday),
Days),
"mm/dd/yyyy"),
"en"));
//////////////////
Set(varMonth,DateAdd(DateValue(Text(varMonth,"mm/dd/yyyy"),"en"),1, Months));
Now it work both on PC and phone.
User | Count |
---|---|
122 | |
87 | |
86 | |
75 | |
67 |
User | Count |
---|---|
214 | |
181 | |
137 | |
96 | |
83 |