TypedDataset with date format

Posts   
 
    
Kris Nobels avatar
Posts: 118
Joined: 02-Apr-2008
# Posted on: 17-Dec-2008 23:43:03   

Hello,

I use mysql as database. My current select is this:


select 
ID , 
DATE_FORMAT(Startdate, '%Y%m%d')as Start_Date, 
room as roomnumber 
from reservations

I have the following question:

Is it possible to create this with Resultset fields in combination with Date_format.


ResultsetFields fields = new ResultsetFields(2);
fields.DefineField(reservationsFields.Id, 0);
fields.DefineField(reservationsFields.Startdate, 1, "Start_Date");
fields.DefineField(reservationsFields.room , 2);


Where or how is it possible to add dateformat '%Y%m%d' as result ?

My result in the datatable must be like this: ID --> 25 Start_Date --> 2008-12-17 room --> Room 17

Kris

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Dec-2008 04:36:21   

Hi Kris, It looks like you need to take advantage of LLBLGen DBFunctionCalls. Give it a try and let us know if you need further help wink

David Elizondo | LLBLGen Support Team
Kris Nobels avatar
Posts: 118
Joined: 02-Apr-2008
# Posted on: 18-Dec-2008 09:58:31   

Thanks for the quick answer smile

I got it to work, it goes like this:


ResultsetFields fields = new ResultsetFields(2);
fields.DefineField(reservationsFields.Id, 0);
fields.DefineField(reservationsFields.Startdate, 1, "Start_Date");
fields.DefineField(reservationsFields.room , 2);

fields[0].ExpressionToApply = new DbFunctionCall("DATE_FORMAT", new object[] { reservationsFields.Startdate, "%Y%m%d" });

thank you.

llblboy
User
Posts: 15
Joined: 18-Apr-2018
# Posted on: 18-Apr-2018 21:52:02   

This worked for me and I'm using MS SQL:

Dim fields As New ResultsetFields(3)

        With fields
            .DefineField(ActualJobTaskFields.TrainName, 0, "TrainName")
            .DefineField(ActualJobTaskFields.TaskDate, 1, "Date")
            .DefineField(ServiceCategoryFields.Name, 2, "Status")
            fields(1).ExpressionToApply = new DbFunctionCall("FORMAT", new object() { ActualJobTaskFields.TaskDate, "MM/dd/yy" })
        End With