Android Question dateutils problem

tufanv

Expert
Licensed User
Longtime User
Hello,

I have 2 strings that keep dates which are at this format : 2014-06-26

When I use dateutils.periodbetweendays(string1,string2) i get an invalid double error because of the "-" charachters. Is there any way to get the days difference with this format. ?

ty
 

MaFu

Well-Known Member
Licensed User
Longtime User
Try this:
B4X:
Dim date1 As String = "2014-06-23"
Dim date2 As String = "2014-06-26"
Dim oldDateFormat As String = DateTime.DateFormat
DateTime.DateFormat = "yyyy-MM-dd"
DateUtils.PeriodBetweenInDays(DateTime.DateParse(date1), DateTime.DateParse(date2))
DateTime.DateFormat = oldDateFormat
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
Hello TY for the reply

I get an eror says :
Unparseable date:"2014-07-21" (at offset 4 )


Try this:
B4X:
Dim date1 As String = "2014-06-23"
Dim date2 As String = "2014-06-26"
Dim oldDateFormat As String = DateTime.DateFormat
DateTime.DateFormat = "yyyy-MM-dd"
DateUtils.PeriodBetweenInDays(DateTime.DateParse(date1), DateTime.DateParse(date2))
DateTime.DateFormat = oldDateFormat
 
Upvote 0

mike2506

Member
Licensed User
Longtime User
B4X:
        DateTime.DateFormat ="dd/MM/yyyy - HH:mm:ss"
    forDate=DateTime.Date(DateTime.now)
    giorno=DateUtils.GetDayOfWeekName(DateTime.Now)   
    giorno=giorno.ToUpperCase
result of compile:
Parsing code. Error
Error parsing program.
Error description: Undeclared variable 'dateutils' is used before it was assigned any value.
Occurred on line: 213
giorno=DateUtils.GetDayOfWeekName(DateTime.Now)

This error is occurs after I've installed DateUtils version 1.05.
With version 1.03 no problem verified.
Thanks for help.
 
Upvote 0

Similar Threads

Top