I'm still new to react(Typescript) and I want to print a date I got from the database but without the time.
here is my Interface:
interface Games {g_Id: number;g_Title: string;g_Genre: string;g_Plattform: string;g_ReleaseDate: Date;g_Price: number;}
and my output method:
private static renderGamesTable(games: Games[]) { console.log(games) return <table className='table'><thead><tr><th>Title</th><th>Genre</th><th>Plattform</th><th>Release Date</th><th>Price</th></tr></thead><tbody> {games.map(games =><tr key={games.g_Id}><td>{games.g_Title}</td><td>{games.g_Genre}</td><td>{games.g_Plattform}</td><td>{games.g_ReleaseDate}</td><td>{games.g_Price}</td></tr> )}</tbody></table>;}
as well as the database design
CREATE TABLE [dbo].[Games] ([G_Id] INT IDENTITY (1, 1) NOT NULL,[G_Genre] NVARCHAR (100) NOT NULL,[G_Plattform] NVARCHAR (100) NOT NULL,[G_Price] DECIMAL (18, 2) NOT NULL,[G_ReleaseDate] DATETIME2 (7) NOT NULL,[G_Title] NVARCHAR (100) NOT NULL,CONSTRAINT [PK_Games] PRIMARY KEY CLUSTERED ([G_Id] ASC));
I'm using .Net core and MS-Sql (i haven't added the fetch method and the controllers since I didn't think they were important, so feel free to ask, if they were).
What I've tried so far is:
- Changing the datatype in the Database
- Trying to convert the Date (using getyear or toDateString ...etc)
- I've tried changing the format using moment
- Creating a new datetype that only accept the date
Nothing seems to work so far (It could be since I'm new I'm missing something obvious, so sorry about that :) )