This is part of my process I’m trying to figure out:
Obtain when the process was last run by referring back to a datetime variable (dtLastRun) which had Now assigned to it (this would be done at the end of the last run of the process)
Download a spreadsheet, work through the column where the survey date is featured, saving the variable as strSurveyTime
Work out if the survey was returned since the process was last run
Issues I’m having:
The dtLastRun is in the American format, i.e. today is 09/05/2023 16:21:12 but the dtLastRun is bringing back 05/09/2023 16:21:12. How would I change this into the UK format?
The strSurveyTime is bringing back the UK format, i.e. 09/05/2023 16:21:12 and is a string format. How can I convert the string into a DateTime variable?
With this, it looks like it’s converting to string so would I still be able to compare the time passed between dtLastRun and dtSurveyTime? (Cdate(yourStringFormat) worked so I’m now using the datetime variable instead of strSurveyTime, thank you!)
Is it possible for you to showcase what you have implemented or tested ?
And we should also be able to use a variable in place of the String value used.
Showcasing of visual implementation and testing done would get rid of the confusions that are present and would allow us to correct our/your findings faster.
Apologies, for some reason one of my work laptops won’t let me upload pictures from it to the Forum, I’ve had to faff around and email the screenshots to my other one.
So I’ve tried someone else’s suggestion of using CDate(strVariable) to convert Now into DateTime but I get this error:
So it originally picked it up in the correct format (SurveyTime org) but when I’ve converted it into a DateTime variable (dtSurveyTime, the second of the write lines) it’s converted back to the US format. It needs to be in DateTime variable format because I need to compare it to another DateTime variable to see if the survey was received after a certain time
I’m trying to change the Now.ToString(“dd/MM/yyyy hh:mm:ss”) to a DateTime variable but it’s not recognising today’s date as a valid date as there’s no 16th month
The first time I run my process, I’ll create the dtNow variable. At the end of the process, I’ll assign a dtLastRun = dtNow so the next time I run the process, I can pick up the dtSurveyTime from the Excel and see if the survey was received after the dtLastRun, so it won’t just be looking at the date it’ll be comparing the time too. Hope that makes sense!
I thought it would be quite easy haha but now I’m finding it a struggle