I’ve been playing around and getting familiar with SambaPOS4/5, Trying to prepare a setup for our Bussiness which we hope to open around springtime . A Campsite with also some B&B rooms. (As soon as the Bussiness is Registerd I’ll buy a License )
To be able to close tickets on customer accounts but still keep track of guests in rooms and/or pitches i’m trying to write Customfields on Rooms.
I’m trying to wite the Current Date to a custom field when a automation command is pressed using report command {DATE}.
The automation command also writes the “Guest” and “NumberGuest” which works fine. But for writing the current date i’m stuck and kind of surprised whats happening.
The result i would expect to see is the current date: 27-10-2015
The result that’s being written in the Custonfields DateCheckIn and DateCheckOut only sometimes will be displayed in the “Batch Entity Editor” although the other customfields, Guest and NumberGuests will be correctly updated. But there is something written in the Custom field if i take a look in the Database (So this probably just will be a Cache Issue).
If you click on the down arrow next to the Custom Field it will jump to the written date in the Calander and display the written Date.
Now the main issue: The dates being written in the Date field are always lowered by 27 in the first Customfield, the second room does something else but seems to caculate also on the first room for how much the Date value is lowered.
(Edit): Today is the 27th, so is it duducting the amount os days of the current date or previous date???
Some examles of written Date in Excel
Can somebody help me?
Am I using the correct format for writing a Date to a custom field or is there a better way to write the Current Date to a Customfield?
Should the {DATE} work over here ?
Is this behaviour as expected or is it some “Bug”? And if it is as expected what is happening?
When field type selected as Date it will process dates as it process date inputs on Report Module’s date filter area. So you can use this format but try removing dash (-) characters between date parts and use space character instead.
The ToString() method applies to DateTime objects, and I believe is a .Net construct, which is what I searched for.
Reducing the code in the link, you might try something like this (not tested)…
EDIT: this is simplified …
// First convert your string into DateTime variable:
var dt = DateTime.Parse(result_depart);
// Then convert this variable back to string in correct format:
var formatted_depart = dt.ToString("dd-MM-yyyy");
Found similar result suggesting DateTime.Parse(result_arrive)
Now puts date into entity field however think maybe I shouldn’t be using to string as now the entity field doesn’t see it as a date but as string LOL
Yah, dates and strings are funny things. Personally, the return value from JSON is the correct representation of date/time, so IMO, I would leave it like that, but to each their own.
However, even your Regional settings may mess with this in the Custom Data field.
You need to decide what works best for you, converting the format and store as string, or leave it be and store as date, or… lots of options.
Just double checked my regional settings as on my tablet and they were US.
But that doesn’t solve the problem.
How does samba want to receive a date?
As it stand the value retuned by depart_todate.ToString("dd MM yyyy") puts the value as expected into the field but doesn’t look like samba takes it as a date (it doesn’t show in the field until you select it, if I use the date picker it shows the date as expected.
If the format retuned by Json I get completely wrong dates.
26/10/15 ends up as 21/04/10
Hmm… Sorry I think I misguided you because what I was talking about here relates with Ticket Tags that accepts date tags. (Like delivery date).
Custom Field’s date thing does nothing more than just displaying a date picker for editor. In all cases value stored as a string value.
What is happening here is our date expression feature (that adds days to dates) works somehow but by chance it does not work when we use spaces between date parts I’ll correct it for next (5.1.55) update.