Formattazione di una data

Forum dedicato ai programmatori di X# in lingua italiana – Italian language forum

Moderator: wriedmann

Post Reply
User avatar
gianluca.pinoli
Posts: 36
Joined: Mon Nov 02, 2015 1:13 pm

Formattazione di una data

Post by gianluca.pinoli »

Ciao a tutti,
ieri ricompilando un progetto dopo l'installazione della versione 2.07 (ma non sono sicuro sia questa la causa del problema) ho cominciato ad avere un errore che riguarda la seguente riga:

sQuery := i"UPDATE infoart SET vecchiocos=oldcos_1,cambiocost='{dData:yyyy-MM-dd}'"

ErroreXS1061'System.DateTime' does not contain a definition for 'yyyy' and no accessible extension method 'yyyy' accepting a first argument of type 'System.DateTime' could be found (are you missing a using directive or an assembly reference?)MeatShopC:UsersGianlucaDocumentsVisual Studio 2019ProjectsMeatShopMeatShopGestioneReseForm.prg977
"ErroreXS1061'System.DateTime'" non è riconosciuto come comando interno o esterno,
un programma eseguibile o un file batch.

Ho risolto il problema modificando la formattazione della stringa in questo modo:
sQuery := String.Format("UPDATE infoart SET vecchiocos=oldcos_1,cambiocost='{0}'",dData:ToString("yyyy-MM-dd"))

Qualcuno sa come fare funzionale la precedente sintassi?

Graze
Gianluca
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Formattazione di una data

Post by wriedmann »

Ciao Gianluca,
teoricamente dovrebbe funzionare anche quella sintassi che ha funzionato in precedenza - possibilmentesi tratta di un errore della 2.07.
Vediamo cosa dice Chris...
Saluti
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Formattazione di una data

Post by Chris »

Hi guys,

Yes, this looks like a bug, that should be supported as well. But it is not a new bug in 2.07, I checked and at least in 2.06 it was the same, not sure if it was working earlier than that. In any case, this will be fixed, thanks for the report!
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply