March 22, 2024 at 12:06 am
I have a sql table where the app is writing. A unix timestamp value to the field. I would like to iterate thru the table and pull from a specific datetime but not sure how to code that in PS that also would export to csv file.
I just pulled the latest record from table --
t_stamp=1711065382576
My Current datetime 3/21/2024 07:56PM
Data Record
7384, , 57.3080520629883 ,, , 192, 1711065382576
CREATE TABLE [dbo].[plc_data_4_2024_03](
[tagid] [int] NOT NULL,
[intvalue] [bigint] NULL,
[floatvalue] [float] NULL,
[stringvalue] [nvarchar](255) NULL,
[datevalue] [datetime] NULL,
[dataintegrity] [int] NULL,
[t_stamp] [bigint] NOT NULL,
PRIMARY KEY CLUSTERED
(
[tagid] ASC,
[t_stamp] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
Thanks.
March 22, 2024 at 12:27 am
you can start by reading the manual - https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-date?view=powershell-7.4
and as alternative, you pass your desired date in date format to your sql, and within the sql itself you convert to your unixtimestamp - which you have already been told many times how to do.
March 22, 2024 at 1:46 am
Why on Earth would you use PoSh to do this? You have the data in a table already.
https://www.sqlservercentral.com/articles/convert-unix-timestamps-to-date-times-in-sql-server-part1
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy